<%-- 
    Document   : main
    Created on : 22/05/2010, 15:00:21
    Author     : leoomoreira
--%>

<%@include file="header.jsp" %>

<% fullalbum.bean.UserAlbum userAlbum = (fullalbum.bean.UserAlbum) request.getAttribute("userAlbum");%>
<% java.util.List<fullalbum.bean.Figure> figureList = (java.util.List<fullalbum.bean.Figure>) request.getAttribute("figureList");%>
<% java.util.List<fullalbum.bean.Figure> rfigureList = new java.util.ArrayList<fullalbum.bean.Figure>(); %>
<% java.util.List<fullalbum.bean.Figure> figureWithinAlbumList = (java.util.List<fullalbum.bean.Figure>) request.getAttribute("figureWithinAlbumList");%>
<% java.util.List<fullalbum.bean.Figure> repeatedFigureWithinAlbumList = (java.util.List<fullalbum.bean.Figure>) request.getAttribute("repeatedFigureWithinAlbumList");%>
<% java.util.List<fullalbum.bean.Figure> figuresUserLoggedList = (java.util.List<fullalbum.bean.Figure>) request.getAttribute("figuresUserLoggedList");%>
<% java.util.List<String[]> threeUsersFigureCountList = (java.util.List<String[]>) request.getAttribute("threeUsersFigureCount");%>
<% java.util.List<fullalbum.bean.Figure> figuresSuggestedByUserLoggedList = (java.util.List<fullalbum.bean.Figure>) request.getAttribute("figuresSuggestedByUserLoggedList");%>
<% String strYouNeed = (String) request.getAttribute("strYouNeed"); %>
<% String strYouExchange = (String) request.getAttribute("strYouExchange"); %>
<table width="720">
    <tr>
        <td width="90"><b><fmt:message key="default.album"/></b>:</td>
        <td class="album">
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td><img src="images/report_user.png" /></td>
                    <td>&nbsp;</td>
                    <td><%= userAlbum.getAlbum().getName()%></td>
                    <td>&nbsp;-&nbsp;</td>
                    <td>
                        <% int position = 0; %>
                        <%
                        for (int i = 0; i < threeUsersFigureCountList.size(); i++) {
                            if (Integer.parseInt(threeUsersFigureCountList.get(i)[0]) == userAlbum.getUser().getId().intValue()) {
                                position = i + 1;
                                break;
                            }
                        }
                        switch (position) {
                            case 1 : {
                                %>
                                <img src="images/award_star_gold_2.png" />&nbsp;
                                <%
                                break;
                            }
                            case 2 : {
                                %>
                                <img src="images/award_star_silver_2.png" />&nbsp;
                                <%
                                break;
                            }
                            case 3 : {
                                %>
                                <img src="images/award_star_bronze_2.png" />&nbsp;
                                <%
                                break;
                            }
                            default : {
                                %>
                                <%
                                break;
                            }
                        }
                        %>
                    </td>
                    <td><%= userAlbum.getUser().getName()%></td>
                    <td>&nbsp;-&nbsp;</td>
                    <td><img src="images/printer.png" /></td>
                    <td>&nbsp;</td>
                    <td><a href="PrintUserAlbumServlet?userId=<%= userAlbum.getUser().getId() %>&albumId=<%= userAlbum.getAlbum().getId()%>" target="_blank"><fmt:message key="default.print"/></a></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td><b><fmt:message key="useralbum.total"/></b>:</td>
        <td class="total"><%= (figureList != null) ? figureList.size() : "0"%></td>
    </tr>
    <tr>
        <td><b><fmt:message key="useralbum.owned"/></b>:</td>
        <td class="owned"><%= (figureWithinAlbumList != null) ? figureWithinAlbumList.size() : "0"%></td>
    </tr>
    <tr>
        <td><b><fmt:message key="useralbum.missing"/></b>:</td>
        <td class="missing"><%= ((figureList != null && figureWithinAlbumList != null) ? (figureList.size() - figureWithinAlbumList.size()) : "0")%></td>
    </tr>
    <tr>
        <td><b><fmt:message key="useralbum.repeated"/></b>:</td>
        <td class="repeated"><span id="repeated"><%= ((repeatedFigureWithinAlbumList != null && repeatedFigureWithinAlbumList != null) ? (repeatedFigureWithinAlbumList.size()) : "0")%></span></td>
    </tr>
    <tr>
        <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
        <td><b><fmt:message key="useralbum.youneed"/></b>:</td>
        <td class="owned">
            <span id="owned">
        <% if (strYouNeed != null && strYouNeed.trim().length() > 0) { %>
            <%= (strYouNeed) %>
        <% } else { %>
            <fmt:message key="default.none"/>
        <% } %>
            </span>
        </td>
    </tr>
    <tr>
        <td><b><fmt:message key="useralbum.youexchange"/></b>:</td>
        <td class="missing">
            <span id="missing">
        <% if (strYouExchange != null && strYouExchange.trim().length() > 0) { %>
            <%= (strYouExchange) %>
        <% } else { %>
            <fmt:message key="default.none"/>
        <% } %>
            </span>
        </td>
    </tr>
</table>
<br />
<span><fmt:message key="default.album"/></span>
<table class="table-album">
    <% int count = 0; %>
    <% while (figureList != null && figureList.size() > 0) { %>
        <% rfigureList.add(figureList.get(0)); %>
        <% if (count == 0) { %>
            <tr>
        <% }%>
        <% if (figureWithinAlbumList.contains(figureList.get(0))) { %>
        <td style="background: #AEAEAE; font-weight: bold;"><%= figureList.remove(0).getId()%></td>
        <% } else { %>
            <% if (figuresSuggestedByUserLoggedList.contains(figureList.get(0))) { %>
        <td style="background: #CD5C5C; font-weight: bold;"><%= figureList.remove(0).getId()%></td>
            <% } else { %>
        <td><%= figureList.remove(0).getId()%></td>
            <% } %>
        <% } %>
        <% count++; %>
        <% if (count == 20) { %>
            </tr>
            <% count = 0; %>
        <% } %>
    <% } %>
    <% while (count > 0) { %>
        <td>&nbsp;</td>
        <% count--; %>
        <% if (count == 0) { %>
            </tr>
        <% } %>
    <% } %>
</table>
<br/>
<span><fmt:message key="useralbum.repeatedfigures"/></span>
<table class="table-album">
    <% int rcount = 0; %>
    <% while (rfigureList != null && rfigureList.size() > 0) { %>
        <% if (rcount == 0) { %>
            <tr>
        <% }%>
        <% if (repeatedFigureWithinAlbumList.contains(rfigureList.get(0))) { %>
        <% if (figuresUserLoggedList.contains(rfigureList.get(0))) { %>
        <td style="background: #AEAEAE; font-weight: bold;"><%= rfigureList.remove(0).getId()%></td>
        <% } else { %>
        <td style="background: #63B8FF; font-weight: bold;"><%= rfigureList.remove(0).getId()%></td>
        <% } %>
        <% } else { %>
        <td><%= rfigureList.remove(0).getId()%></td>
        <% } %>
        <% rcount++; %>
        <% if (rcount == 20) { %>
            </tr>
            <% rcount = 0; %>
        <% } %>
    <% } %>
    <% while (rcount > 0) { %>
        <td>&nbsp;</td>
        <% rcount--; %>
        <% if (rcount == 0) { %>
            </tr>
        <% } %>
    <% } %>
</table>
<%@include file="footer.jsp" %>